package pl.edu.pw.perg.compinfodb.manager;

import java.util.Collection;
import java.util.List;

import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import pl.edu.pw.perg.compinfodb.dao.IGenericDAO;

public class GenericManager<T> implements IManager<T> {

	private IGenericDAO<T> genericDAO;

	public IGenericDAO<T> getGenericDAO() {
		return genericDAO;
	}

	public void setGenericDAO(IGenericDAO<T> genericDAO) {
		this.genericDAO = genericDAO;
	}
	@Transactional(readOnly = false, propagation = Propagation.REQUIRED)
	public List<T> findAll() {
		return genericDAO.findAll();
	}
	@Transactional(readOnly = false, propagation = Propagation.REQUIRED)
    public T findById(Long id) {
        return genericDAO.findById(id);
    }	
	@Transactional(readOnly = false, propagation = Propagation.REQUIRED)
	public void saveAll(Collection<T> items) {
		genericDAO.saveAll(items);
	}
	@Transactional(readOnly = false, propagation = Propagation.REQUIRED)
	public void save(T item) {
		genericDAO.save(item);
	}
    @Transactional(readOnly = false, propagation = Propagation.REQUIRED)
    public void deleteAll() {
        genericDAO.deleteAll();
    }	


}
